package com.cjg.netCode;

import com.sun.source.tree.NewArrayTree;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class netServerUdp {
    public static void main(String[] args) throws Exception {
        // 开放端口
        DatagramSocket datagramSocket = new DatagramSocket(7777);
        //接收数据
        byte[] bytes = new byte[1024];
        DatagramPacket datagramPacket = new DatagramPacket(bytes,0,bytes.length);

        datagramSocket.receive(datagramPacket);

        System.out.println(new String(datagramPacket.getData(),0,datagramPacket.getLength()));
        System.out.println();
        datagramSocket.close();

    }

}
